import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import Index from '../views/index'

export const routes = [
	{
		path: '/',
		component: Index,
	},
	{
		path: '/ui',
		name: 'Ui',
		component: () => import('../views/ui/'),
		children: [
			{
				path: 'button',
				name: 'Button',
				component: () => import('../views/widget/Button'),
				meta: {
					title: 'Button'
				}
			},{
				path: 'cell',
				name: 'Cell',
				component: () => import('../views/widget/Cell'),
				meta: {
					title: 'Cell'
				}
			},{
				path: 'popup',
				name: 'Popup',
				component: () => import('../views/widget/Popup'),
				meta: {
					title: 'Popup'
				}
			},{
				path: 'dialog',
				name: 'Dialog',
				component: () => import('../views/widget/Dialog'),
				meta: {
					title: 'Dialog'
				}
			},{
				path: 'nav-bar',
				name: 'NavBar',
				component: () => import('../views/widget/NavBar'),
				meta: {
					title: '导航'
				}
			},{
				path: 'share-sheet',
				name: 'ShareSheet',
				component: () => import('../views/widget/ShareSheet'),
				meta: {
					title: 'ShareSheet'
				}
			},{
				path: 'search',
				name: 'Search',
				component: () => import('../views/widget/Search'),
				meta: {
					title: 'Search'
				}
			},{
				path: 'input',
				name: 'Input',
				component: () => import('../views/widget/Input'),
				meta: {
					title: 'Input'
				}
			},{
				path: 'stepper',
				name: 'Stepper',
				component: () => import('../views/widget/Stepper'),
				meta: {
					title: 'Stepper'
				}
			},{
				path: 'action-sheet',
				name: 'ActionSheet',
				component: () => import('../views/widget/ActionSheet'),
				meta: {
					title: 'ActionSheet'
				}
			},{
				path: 'tab',
				name: 'Tab',
				component: () => import('../views/widget/Tab'),
				meta: {
					title: 'Tab'
				}
			},{
				path: 'grid-icon',
				name: 'GridIcon',
				component: () => import('../views/widget/GridIcon'),
				meta: {
					title: 'GridIcon'
				}
			},{
				path: 'skeleton',
				name: 'Skeleton',
				component: () => import('../views/widget/Skeleton'),
				meta: {
					title: 'Skeleton'
				}
			},{
				path: 'swiper',
				name: 'Swiper',
				component: () => import('../views/widget/Swiper'),
				meta: {
					title: 'Swiper'
				}
			},
		]
	},
]

const createRouter = () => new Router({
	// mode: 'history', // require service support
	scrollBehavior: () => ({
		y: 0
	}),
	routes
})

const router = createRouter()


// router.beforeEach((to, from, next) => {
//   let { meta } = to
//   let { title } = meta

// 	next()
//   return
// })

// router.afterEach(() => {
  
// })

export default router